#!/bin/sh
source "${LMD_BASE_INSTALL_SCRIPT_DIR}/global/sys_check.sh"
APP_TARGET_DIR_NAME="openshot"

echo "lmdprogress:10"

export CURRENT_APP_PATH="${LMD_APPS_DIR}/${APP_TARGET_DIR_NAME}"
echo $CURRENT_APP_PATH

if [ -d "$CURRENT_APP_PATH" ]; then
    echo "App Dir: "$CURRENT_APP_PATH
else
    echo "Error, App Dir dose not exist $CURRENT_APP_PATH"
    echo "lmdprogress:100"
    exit 1
fi

echo "lmdprogress:40"


function remove_app_win {
  echo "Find install path."
  cd "$CURRENT_APP_PATH/install_dir"
  echo "call unins000.exe"
  "./unins000.exe" //silent
}

if [ -f /System/Library/CoreServices/SystemVersion.plist ]; then
    echo "macOS"
    echo "this script is for windows."
    exit 1
elif current_os_is_windows; then
    echo "Windows"
    echo "lmdprogress:50"
    remove_app_win

    cd "$LMD_APPS_DIR"
    echo 'remove app files'
    rm -rf "$CURRENT_APP_PATH"
    echo "lmdprogress:100"
fi
